package me.zk.practice1.hw;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class HWBJ20 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();

        String[] strs = s.split(",");

        if (strs.length == 1) {
            System.out.println(Integer.parseInt(strs[0]));
            return;
        }
        if (strs.length == 2) {
            System.out.println(Integer.min(Integer.parseInt(strs[0]+Integer.parseInt(strs[1])),
                    Integer.parseInt(strs[1]+Integer.parseInt(strs[0]))));
            return;
        }

        int min = Integer.MAX_VALUE;
        boolean[] used = new boolean[strs.length];
        List< List<String>> all = new ArrayList<>();

        List<String> list = new ArrayList<>();

        dfs(all,list,used,strs,0);
        for(List<String> list1 : all) {
            StringBuffer sb = new StringBuffer();
            for (String s1 : list1) {
                sb.append(s1);
            }
            min = Integer.min(min,Integer.parseInt(sb.toString()));
        }
        System.out.println(min);
    }

    public static void dfs(List< List<String>> all, List<String> list, boolean[] used,String[] strs,int index) {
        if (index == 3) {
            all.add(new ArrayList<>(list));
            return;
        }
        for (int i = 0; i < strs.length; i++) {
            if (used[i]) {
                continue;
            }
            list.add(strs[i]);
            used[i] = true;
            dfs(all,list,used,strs,index+1);
            used[i]= false;
             list.remove(list.size()-1);
        }
    }
}
